package org.jeecg.modules.common.rabbitmq;

import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.stereotype.Component;

/**
 * @author Wq
 */
@Component
public class RabbitmqUtil {

    /**
     * 交换机绑定队列
     * @param archivesExchange 交换机
     * @param archivesQueue 队列
     * @param archivesRoutingKey 路由key
     */
    public void archivesBinding( String archivesExchange, String archivesQueue, String archivesRoutingKey){
        BindingBuilder.bind(archivesQueue(archivesQueue)).to(archivesExchange(archivesExchange)).with(archivesRoutingKey);
    }

    /**
     * 添加topic交换机
     * @param archivesExchange 交换机名称
     */
    private TopicExchange archivesExchange(String archivesExchange){
        return new TopicExchange(archivesExchange, true, false);
    }

    /**
     * 添加队列
     * @param archivesQueue 队列名称
     */
    private Queue archivesQueue(String archivesQueue){
        return new Queue(archivesQueue,true,false,false);
    }
}
